<include file="Public/header"/>

		<div id="app">
			<!-- sidebar -->
			<include file="Public/left"/>
			<!-- / sidebar -->
			<div class="app-content">
				<!-- start: TOP NAVBAR -->
				<include file="Public/headernav"/>
				<!-- end: TOP NAVBAR -->
				<div class="main-content" >
					<div class="wrap-content container" id="container">
						<!-- start: PAGE TITLE -->
						<section id="page-title">
							<div class="row">
								<div class="col-sm-8">
									<h1 class="mainTitle">{$data.type_name}</h1>
									<span class="mainDescription">{$msgtitle}</span>
								</div>
								
							</div>
						</section>
						<!-- end: PAGE TITLE -->
						<!-- start: YOUR CONTENT HERE -->
<div class="container-fluid container-fullw bg-white">
<form action="" role="form" id="form2" novalidate="novalidate" method="post">
<div class="row">
	<div class="col-md-6">
     <div class="form-group">
		<label class="control-label">
			展示标题<span class="symbol required" aria-required="true"></span>
		</label>
		<input type="text" name="title" value="{$data.title}" id="title" placeholder="展示标题" class="form-control">
	</div>
    <div class="form-group" id="show_type">
        <label class="control-label">
            展示类型<span class="symbol required" aria-required="true"></span><span style="color:red;">限时商品关联的活动时间为选择限时商品的活动时间</span>
        </label>
        <select name="sel_type" class="form-control" id="sel_type">
            <option value="0">-展示类型-</option>
            <option value="1" <if condition="$data.type eq 1">selected</if>>商品关联</option>
            <option value="2"
            <if condition="$data.type eq 2">selected</if>>类别关联</option>
            <option value="3"
            <if condition="$data.type eq 3">selected</if>>限时商品关联</option>
        </select>
    </div>
        <input id="value" type="hidden" name="value" value="{$data.value}">
    <if condition="!empty($_GET['type'])">
        <div class="form-group" id="show_value">
            <label class="control-label">
                展示内容<span class="symbol required" aria-required="true"></span>
            </label>
            <input type="button" value="选择展示内容" onclick="setValue({$data.type})" class="btn btn-primary" />
            <br><br>
            <div style="display: block;" id="title_t">
                <if condition="is_array($data['title_t'])">
                    <volist name="data['title_t']" id="vo">
                        {$vo}<br>
                    </volist>
                    <else/>
                    {$data.title_t}
                </if>
            </div>
            <br>
            <!--<input type="text" placeholder="展示内容" value="{$data.value}" onclick="setValue({$data.type})" class="form-control" readonly>-->
        </div>
    </if>
    <div class="form-group show_time" <if condition="$data.type eq 3"> style="display:none"</if> >
        <label class="sr-only">
            活动时间
        </label>
        <p class="input-group input-append datepicker_hour date"
           data-date-format="yyyy-mm-dd hh:ii:ss">
            <input type="text" class="form-control" id="star_time" name="start_time" placeholder="开始时间"
                   value="{$data['start_time']|date='Y-m-d H:i:s',###}"
                   readonly/>
            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
        </p>
        <p class="input-group input-append datepicker_hour date"
           data-date-format="yyyy-mm-dd hh:ii:ss">
            <input type="text" class="form-control" id="end_time" name="end_time"
                   value="{$data['end_time']|date='Y-m-d H:i:s',###}" placeholder="结束时间" readonly/>
            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
        </p>
    </div>
    <if condition="$data.type eq 3">
    <div class="form-group"  >
        <label class="control-label">
               限时商品活动时间
            </label>
        <p class="input-group ">
           {$data['start_time']|date='Y-m-d H:i:s',###}至{$data['end_time']|date='Y-m-d H:i:s',###}
        </p>
    </div>
    </if>
    <div class="form-group">
        <label class="control-label">
            展示图片（600*300）
        </label> 
        <br>
        <div class="upload_file">
           <label>
         <input type="file" name="head_photo" class="upload_input" id="head_photo" value="" style="display:none;"> 
          <div class="fileinput fileinput-new" data-provides="fileinput">
                <div class="fileinput-new thumbnail" id="show_photo">
                    <img id="head_photo_src" src="{:U('wap/index/get_thumbs',array('auto'=>300))}?img={$data.image_path}" alt="">
                </div>
            </div>
           点击图片上传
        </label>
         </div>
          <input type="hidden" name="image_path" id="image_path" value="{$data.image_path}">
    </div>
    <!--<div class="form-group">-->
        <!--<label class="control-label">-->
            <!--介绍-->
        <!--</label>-->
        <!--<div>-->
            <!--<textarea id="des" name="des"  class=" autosize" data-autosize-on="true" style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 100px;">{$data.des}</textarea>-->
             <!--加载编辑器的容器-->

             <!--<input type="hidden" name="msg" id="msg" value="">-->
            <!--</div>-->
    <!--</div>-->

 <div class="form-group">
        <label class="control-label">
            排序（值越大越靠前）
        </label>
        <input type="text" name="sort" value="{$data.sort|default='0'}" id="sort" placeholder="排序" class="form-control">
    </div>
	
 <div class="form-group">
		<label class="control-label">
			状态 <span class="symbol required" aria-required="true"></span>
		</label>
		<select class="form-control"   name="status">
			<if condition="$data.id gt 0">
			<option value="1" <if condition="$data.status eq 1">selected</if> >有效</option>
            <option value="0" <if condition="$data.status eq 0">selected</if> >无效</option>
            <else/>
            <option value="1">有效</option>
            <option value="0">无效</option>
            </if>
		</select>
	</div>



</div>
</div>
<div class="row">
<div class="col-md-4">
	<input type="hidden"  value="{$data.id}" name="id">
	<input type="hidden"  value="{$data.type}" name="type">
	<button class="btn btn-primary btn-wide pull-left" type="submit">
		提交 <i class="fa fa-arrow-circle-right"></i>
	</button>
</div>

<div class="col-md-8">
	<p>
		
	</p>
</div>

</div>											
</form>
</div>
						<!-- end: YOUR CONTENT HERE -->
					</div>
				</div>
			</div>
			<!--  FOOTER and SETTINGS -->
           <include file="Public/footer"/>
			<!-- end: FOOTER -->
			<!-- start: OFF-SIDEBAR -->
			
			<!-- end: OFF-SIDEBAR -->
			
		</div>
		<!-- start: MAIN JAVASCRIPTS -->

         <include file="Public/javascript"/>
         <include file="Public/javascript_datepicker"/>
		<!-- end: CLIP-TWO JAVASCRIPTS -->

		<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<script src="__PUBLIC__/bootstrap/vendor/ckeditor/ckeditor.js"></script>
		<script src="__PUBLIC__/bootstrap/vendor/ckeditor/adapters/jquery.js"></script>
		<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.min.js"></script>
		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<!-- start: CLIP-TWO JAVASCRIPTS -->
		<!-- <script src="__PUBLIC__/bootstrap/assets/js/main.js"></script> -->
		<!-- start: JavaScript Event Handlers for this page -->
		<!--<script src="__PUBLIC__/bootstrap/assets/js/form-validation.js"></script>-->

		

		<script src="__PUBLIC__/bootstrap/vendor/artDialog/artDialog.source.js?skin=default"></script>
       <script src="__PUBLIC__/bootstrap/vendor/artDialog/plugins/iframeTools.source.js"></script>

       <script src="__PUBLIC__/bootstrap/vendor/ajaxfileupload/ajaxfileupload.js"></script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->

		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<!-- start: CLIP-TWO JAVASCRIPTS -->
		<!-- <script src="__PUBLIC__/bootstrap/assets/js/main.js"></script> -->
		<!-- start: JavaScript Event Handlers for this page -->
		<!--<script src="__PUBLIC__/bootstrap/assets/js/form-validation.js"></script>-->
<script type="text/javascript">
        $('#sel_type').change(function () {
            var type_val = $('#sel_type').val();
            var content = '<div class="form-group" id="show_value">' +
                    '<label class="control-label">' +
                    '展示内容<span class="symbol required" aria-required="true"></span></label>' +
                    '<input type="button" value="选择展示内容" onclick="setValue('+type_val+')" class="btn btn-primary" />'+
                    '<br><br><div style="display: block;" id="title_t"></div><br>';
            $('#show_value').remove();
            if (type_val != 0) {
                $('#show_type').after(content);
                if(type_val=='3'){
                   $('.show_time').hide();
                }else{
                   $('.show_time').show();
                }
            }
        })
        function setValue(type) {
            var value=$('.value').val();
            layer.open({
                type: 2,
                title: '请选择展示内容',
                shadeClose: true,
                shade: 0.8,
                area: ['80%', '90%'],
                content: '{:U("admin/Ad/popup_type")}?type='+type+'&value='+value,
            })
        }
    jQuery(document).ready(function() {   //表单验证
//FormValidator.init();
        $("#form2").validate({
          rules: {
              title:"required",
              image_path:"required",
              value:"required",
              sel_type:{
                  range:[1,3]
              }
          },
          messages: {
              title: "请输入展示标题",
              image_path:"请上传展示图片",
              value:"请选择展示内容",
              sel_type:{
                range:'请选择正确的展示类型'
              }
          }
          })
        })
</script>
<script type="text/javascript">
    $(document).ready(function (e) {
         ///上传商家logo
        $('.upload_file').on('change','.upload_input', function () {
             ajaxFileUploadview('head_photo', 'goods_image', "{:U('admin/Imagecat/upload_ajax')}");
       
        });

        $('.goods_image_url').on('click','.delete_img', function () {
        	if(confirm('您确定删除该图片？')){
              $(this).parents('.fileinput').remove();
        	}
        });

    });

//文件上传带预览
    function ajaxFileUploadview(imgid, hiddenid, url) {

        $.ajaxFileUpload({
                    url: url,
                    secureuri: false,
                    fileElementId: imgid,
                    dataType: 'json',
                    data: {name: 'logan', id: 'id'},
                    success: function (data, status)
                    {
                      
                        if (typeof (data.error) != 'undefined')
                        {
                              
                            if (data.error != '')
                            {
                                var dialog = art.dialog({title: false, fixed: true, padding: 0});
                                dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            } else {

                                var resp = data.msg;
                                if (resp != '0000') {
                                    var dialog = art.dialog({title: false, fixed: true, padding: 0});
                                    dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                                    return false;
                                } else {
                                    $('#head_photo_src').attr('src',data.imgurl);
                                    $('#image_path').val(data.imgurl);

                                   /* art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
                                        title: '裁剪图片',
                                        width: '800px',
                                        height: '400px'
                                    });*/

                                    //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                                }
                            }
                        }
                    },
                    error: function (data, status, e)
                    {
                        var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        dialog.time(3).content("<div class='tips'>" + e + "</div>");
                    }
                })

        return false;
    }
</script>		
		<!-- end: JavaScript Event Handlers for this page -->
	</body>
</html>
